﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>


    </style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>审核流程</legend>
            </fieldset>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                </div>
            </script>
            <input type="hidden" name="ID" value="@ViewBag.ID" id="ID"/>
            <table class="layui-hide" id="table" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
                <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
            </script>
        </div>
    </div>
    <script src="~/layui/layui.js"></script>
    <script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#table',
            method:'post',
            url: '@Url.Action("AuditingFlowListAsync", "BasicInfo")',
            request: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
               ,limitName: 'PageSize' //每页数据量的参数名，默认：limit
            },
            where:{
                ID:$('#ID').val(),
            },
        toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                { field: 'RowIndex', title: '序号'},
                { field: 'UserName', title: '审核人' },
                { fixed: 'right', title: '操作', toolbar: '#currentTableBar', width: 150 }
            ]],
            limits: [10, 20, 30, 50, 100, 100000000],
            limit: 20,
            page: false,
            //skin: 'line',
            //totalRow: true,
            height: 'full-170',
            //size:'sm',
        });


        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加审核流程',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: false,
                    area: ['400px', '300px'],
                    content: '@Url.Action("AuditingFlowEdit", "BasicInfo")'+'?AuditingID='+$('#ID').val(),
                    end: function () {
                        RefreshTable();

                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {

                var index = layer.open({
                    title: '修改审核流程',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: false,
                    area: ['400px', '300px'],
                    content: '@Url.Action("AuditingFlowEdit", "BasicInfo")'+'?AuditingID='+$('#ID').val()+'&ID='+data.ID,
                    end: function () {
                        RefreshTable();
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {

                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("AuditingFlowDelAsync")',
                        type: "post",
                        dataType: "json",
                        data: { IDs: data.ID },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } 
        });
        function RefreshTable() {
            table.reload('table', {
                where: {
                    ID: $('#ID').val(),
                }
            }, 'data');

        }
    });
    </script>
</body>
</html>